import random

setGlobalDuration(-1)

env = genAdsr()

beginPythonInst(1)
sine(duration=.25, envelope=env)
endPythonInst()

proc = startCsound()

def event():
    dict = {'sine': {'pitch': random.choice([200,250,300,350,400,500,600])}}
    sendEvent(1, dict, proc)

a = pattern(.125, event, [1,1,1,1,2])
a.start()
a.play()